package cn.mrcode.smartPluginSecurity;

import cn.mrcode.smartFramework.helper.ConfigHelper;
import cn.mrcode.smartFramework.utils.ReflectionUtil;

/**
 * @author zhuqiang
 * @version V1.0
 * @date 2015/11/16 21:33
 */
public class SecurityConfig {
    public static String getRealms(){
        return ConfigHelper.getString(SecurityConstant.REALMS);
    }

    /**
     * 加载 配置文件中，配置的jdbcRealm的辅助接口
     * @return
     */
    public static SmartSecurity getSmartSecurity() {
        String className = ConfigHelper.getString(SecurityConstant.SMART_SECURITY);
        return (SmartSecurity) ReflectionUtil.newInstance(className);
    }

    /**
     * 获取配置项目，是否启用缓存
     * @return
     */
    public static boolean isCache() {
        return ConfigHelper.getBoolean(SecurityConstant.CACHE);
    }

    public static String getAuthenticationQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_AUTHC_QUERY);
    }

    public static String getUserRolesQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_ROLES_QUERY);
    }

    public static String getPermissionsQuery() {
        return ConfigHelper.getString(SecurityConstant.JDBC_PERMISSIONS_QUERY);
    }
}
